package com.xbongbong.saas.model.impl;

import com.xbongbong.saas.domain.dao.DingBundleRankDao;
import com.xbongbong.saas.domain.entity.DingBundleRankEntity;
import com.xbongbong.paas.toolbox.util.DateUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

import com.xbongbong.saas.model.DingBundleRankModel;

/**
 * @author chenshan
 * @version v1.0
 * @since 2019-08-16 10:50
 */
@Service("dingBundleRankModel")
public class DingBundleRankModelImpl implements DingBundleRankModel {
    
    @Resource
    private DingBundleRankDao dingBundleRankDao;

    @Override
    public Integer insert(DingBundleRankEntity entity) {
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        return dingBundleRankDao.insert(entity);
    }

    @Override
    public void insertBatch(List<DingBundleRankEntity> DingBundleRankList) {
        dingBundleRankDao.insertBatch(DingBundleRankList);
    }

    @Override
    public Integer save(DingBundleRankEntity entity) {
        if ( entity.getId() == null || entity.getId().equals(0L) ) {
            return insert(entity);
        }
        return update(entity);
    }

    @Override
    public Integer update(DingBundleRankEntity entity) {
        return dingBundleRankDao.update(entity);
    }

    @Override
    public DingBundleRankEntity getEntity(Long id, String corpid) {
        return dingBundleRankDao.getByKey(id, corpid);
    }

    @Override
    public Integer deleteByIds(List<Long> ids, String corpid) {
        return null;//dingBundleRankDao.deleteByIds(ids, corpid);
    }

    @Override
    public List findEntitys(Map<String, Object> param) {
        return dingBundleRankDao.findEntitys(param);
    }
    
    @Override
    public Integer deleteByRecordTime(String corpid, String openConversationId, Long rankTimeStart, Long rankTimeEnd) {
        return dingBundleRankDao.deleteByRankTime(corpid,openConversationId,rankTimeStart,rankTimeEnd);
    }
    
    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return dingBundleRankDao.getEntitysCount(param);
    }
    
    /**
     * Description: 查询符合条件的数据（无子表单数据）
     *
     * @param param
     * @return java.util.List<T>
     * @throws
     * @author 魏荣杰
     * @date 2020/10/13 16:07
     * @since
     */
    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }
    
    @Override
    public Integer updateBatch(List<Long> ids, String corpid, Integer isPush, String pushUrl) {
        return dingBundleRankDao.updateBatch(ids,corpid,isPush,pushUrl);
    }

    @Override
    public Integer dataConsistencyUpdateUser(String corpid, String userId, String name, String avatar) {
        return dingBundleRankDao.dataConsistencyUpdateUser(corpid, userId, name, avatar);
    }
}